<?php
class indexControl extends Control{
    function index(){
        $db = K("newsview");
        $row = $db -> where("id=110") -> where("news.catid=123")->find();
        //公司介绍；
        $this -> assign("us",$row); 
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //招聘信息；
        $job = job();
        $this-> assign("job",$job);
        //分页类；
        $row = paged("job","id",5); 
        $this->assign("row",$row[0]);
        $this->assign("pages",$row[1]);
        $this->display();
    }

    function company(){
        $db = K("newsview");
        $row = $db -> where("id=110")->find();
        //公司介绍；
        $this -> assign("us",$row); 
        //左边的表；
        $res = left();
        $this -> assign("table",$res);
    	$this->display();
    }

    function job(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //招聘信息；
        $job = job();
        $this-> assign("job",$job);
        //分页类；
        $db = M("job");
        $count = $db -> count("id");  //获得总条数；
        $page = new page($count,3);     //每页显示几条；
        $row = $db->limit($page->limit())->findall();   //显示每页的记录；
        $this->assign("row",$row);
        $this->assign("pages",$page->show(2));
    	$this->display();
    }

    function news(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //新闻表
        $db = K("newsview");
        $res = $db -> where("news.catid=124") ->findall();
        $this -> assign("news",$res);
        //分页类；
        $db = K("newsview");
        $count = $db -> count("id");  //获得总条数；
        $page = new page($count,5);     //每页显示几条；
        $row = $db-> where("news.catid=124")->limit($page->limit())->findall();   //显示每页的记录；
        $page_show = $page->show(2);
        $this->assign("row",$row);
        $this->assign("pages",$page_show);
    	$this->display();
    }

    function image(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
    	$this->display();
    }

    function contact(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //反馈意见表
        $db = M("contact");
        $res = $db -> findall();
        $this -> assign("contact",$res);
        //分页类；
        $row = paged("contact","id",5); 
        $this->assign("row",$row[0]);
        $this->assign("pages",$row[1]);
    	$this->display();
    }

    function show_news(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //显示页面右部分内容；
        $num = $_GET['id'];
        $result = showds("newsview",$num);
        $this -> assign("news_info",$result);
        $this->display();
    }

    function show_job(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //显示页面右部分内容；
        $num = $_GET['id'];
        $db = M("job");
        $result = $db  -> find($num);
        $this -> assign("job",$result);
        $this->display();
    }

    function show_advice(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        //显示页面右部分内容；
        $num = $_GET['id'];
        $result = showd("contact",$num);
        $this -> assign("advice",$result);
        $this -> display();
    }

    function add(){
        $db = M("contact");
        $_POST["addtime"] = time();
        if($db->add()){
            $this->success("数据添加成功！");
        }else{
            $this->error("数据添加失败");
        }
    }

    function img(){
        //左边的表
        $res = left();
        $this -> assign("table",$res);
        $db = M("img");
        $rows = $db -> findall();
        $this-> assign("rows",$rows);
        $this->display();
    }

    function aaa(){
        echo 1; 
    }
    
}